﻿
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Configuration;
using Himall.Core;
using Himall.CommonModel;


namespace Himall.Entity
{
    public partial class ProductInfo
    {
        
        //[NotMapped]
        //public ProductDescriptionInfo ProductDescriptionInfo
        //{
        //    get {
        //        if (ProductDescriptionInfoList != null || ProductDescriptionInfoList.Count == 1)
        //        {
        //            return ProductDescriptionInfoList[0];
        //        }
        //        else {
        //            return null;
        //        }
        //    } set {
        //        if (ProductDescriptionInfoList != null || ProductDescriptionInfoList.Count == 1)
        //        {
        //            ProductDescriptionInfoList[0] = value;
        //        }
        //        else {
        //            ProductDescriptionInfoList = new List<ProductDescriptionInfo>() { value };
        //        }
        //    }
        //}



        [NotMapped]
        public int ConcernedCount { get; set; }

        /// <summary>
        /// 获取图片地址 YZY修改获取不同尺寸图片的方法
        /// </summary>
        /// <param name="imageIndex">图片序号</param>
        /// <param name="imageSize">图片尺寸</param>
        /// <returns></returns>
        public string GetImage(ImageSize imageSize, int imageIndex = 1)
        {
           // return string.Format(ImagePath + "/{0}_{1}.png", imageIndex, (int)imageSize);
            return Core.HimallIO.GetProductSizeImage(imagePath, imageIndex, (int)imageSize);
        }


        /// <summary>
        /// 图片路径
        /// </summary>
     
        public string ImagePath
        {
          //  get { return ImageServerUrl + imagePath; }

            get { return Core.HimallIO.GetImagePath(imagePath); }
            set
            {
                if (!string.IsNullOrWhiteSpace(value) && !string.IsNullOrWhiteSpace(ImageServerUrl))
                    imagePath = value.Replace(ImageServerUrl, "");
                else
                    imagePath = value;
            }
        }
        [NotMapped]
        public string RelativePath
        {
            get { return imagePath; }
        }

        /// <summary>
        /// 成交数
        /// </summary>
        [NotMapped]
        public long OrderCounts { get; set; }

        /// <summary>
        /// 商品地址
        /// </summary>
        [NotMapped]
        public string Address { get; set; }

        /// <summary>
        /// 店铺名称
        /// </summary>
        [NotMapped]
        public string ShopName { get; set; }

        [NotMapped]
        public string BrandName
        {
            get;
            set;
        }

        #region 表单传参用
        [NotMapped]
        public string CategoryNames { get; set; }

        [NotMapped]
        public int IsCategory { get; set; }

        [NotMapped]
        public long TopId { get; set; }

        [NotMapped]
        public long BottomId { get; set; }
        #endregion

        [NotMapped]
        public string ShowProductState
        {
            get
            {
                string result = "错误数据";
                if (this != null)
                {
                    if (this.AuditStatus == ProductAuditStatus.WaitForAuditing)
                    {
                        result = (this.SaleStatus == ProductSaleStatus.OnSale ? ProductAuditStatus.WaitForAuditing.ToDescription() :
                ProductSaleStatus.InStock.ToDescription());
                    }
                    else
                    {
                        result = this.AuditStatus.ToDescription();
                    }
                }
                return result;
            }
        }
    }
}
